package com.code.vo;

import java.util.ArrayList;
import java.util.List;

import net.sf.ezmorph.object.DateMorpher;
import net.sf.json.JSONObject;
import net.sf.json.util.JSONUtils;

import com.code.iface.ITree;

public class TreeVO implements ITree {
	
	private ITree tree;
	private List<TreeVO> children = new ArrayList<TreeVO>();
	private String attrJson;
	
	public TreeVO(ITree tree) {
		this.tree = tree;
		JSONUtils.getMorpherRegistry().registerMorpher(new DateMorpher(new String[]{"yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd"}));
		attrJson = JSONObject.fromObject(tree).toString();
	}

	public List<TreeVO> getChildren() {
		return children;
	}

	public void setChildren(List<TreeVO> children) {
		this.children = children;
	}

	public String getAttrJson() {
		return attrJson;
	}

	public void setAttrJson(String attrJson) {
		this.attrJson = attrJson;
	}

	public Long getId() {
		return tree.getId();
	}

	public Boolean getLeaf() {
		return tree.getLeaf();
	}

	public String getText() {
		return tree.getText();
	}

	public Long getParentId() {
		return tree.getParentId();
	}
	
}
